package com.ljy.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ljy.mapper.BackendMapper;
import com.ljy.pojo.App_category;
import com.ljy.pojo.App_info;
import com.ljy.pojo.Backend_user;
import com.ljy.pojo.Data_dictionary;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

public class BackendServiceIMP implements BackendService {

    //service调用dao层 组合
    private BackendMapper mapper;

    public void setMapper(BackendMapper mapper) {
        this.mapper = mapper;
    }


    /**
     * 后台管理登录
     *
     * @param userCode
     * @param userPassword
     * @return
     */
    public Backend_user Login(String userCode, String userPassword) {
        return mapper.Login(userCode, userPassword);
    }

    /**
     * 所属平台
     *
     * @return
     */
    public List<Data_dictionary> Their() {
        return mapper.Their();
    }

    /**
     * 二级分类
     *
     * @return
     */
    public List<App_category> classify(int id) {
        return mapper.classify(id);
    }

    /**
     * 查询所有app信息
     *
     * @return
     */
    public List<App_info> queryByAppinfoAll(App_info appInfo) {
        return mapper.queryByAppinfoAll(appInfo);
    }


    /**
     * 分页
     *
     * @param appInfo  条件
     * @param pageNum  当前页码
     * @param pageSize 每页行数
     * @return
     */
    public PageInfo<App_info> findPage(App_info appInfo, int pageNum, int pageSize) {
        return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> {
            mapper.queryByAppinfoAll(appInfo);
        });
    }

    /**
     * 根据编号查询app信息
     *
     * @param id
     * @return
     */
    public Map queryByAppinfo(Integer id) {
        return mapper.queryByAppinfo(id);
    }

    /**
     * 根据编号查询当前app版本信息
     *
     * @param
     * @return
     */
    public Map queryByVersion(Integer id) {
        return mapper.queryByVersion(id);
    }

    /**
     * 修改状态为审核
     *
     * @param status
     * @param id
     * @return
     */
    public int updateByStatus(int status, int id) {
        return mapper.updateByStatus(status, id);
    }
}
